import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isLogin: false,
    account: ''
  },
  mutations: {
    userStatus(state, payload) {  // 登录更新用户的status
      state.isLogin = payload.isLogin;
      state.account = payload.account;
    },
    userStatusSessionStorage(state, payload) {  // 刷新时使用，sessionStorage会将所有的值转为字符串存储
      state.isLogin = payload.isLogin === 'true';
      state.account = payload.account;
    }
  },
  actions: {},
  modules: {}
})
